#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[])
{
    FILE *fp;
    long count, last;
    char ch;
    char words[50];
    // char *p;

    if ((fp=fopen("../text/random_access.txt", "rb"))==NULL){
        printf("Open fail!");
        exit(EXIT_FAILURE);
    }

    // while ((p = fgets(words, 50-1, fp)) != NULL) {
    //     fputs(words, stdout);
    // }
    fseek(fp, 0L, SEEK_END);
    last = ftell(fp);
    for ( count = 0L; count <= last; count++) {
        fseek(fp, count, SEEK_SET);
        ch = fgetc(fp);
        if (ch != EOF && ch != '\r') {
            putchar(ch);
        }
    }

    fclose(fp);

    return 0;
}
